import pyodbc
import pandas as pd
driver = '{SQL Server}'
server = '127.0.0.1'
user = 'sa'
password = '56321478965'
database = 'game'
conn = pyodbc.connect(driver=driver, user=user, server=server, password=password, database=database)
cursor = conn.cursor()
sql="select * from orders where rating is not null"
df = pd.read_sql_query(sql, conn)
df.to_csv("output.csv")

